package com.tentact.servlets;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.tentact.service.Chf_MeetingService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "Chf_judgeMeetingNameServlet", value = "/Chf_judgeMeetingNameServlet")
public class Chf_judgeMeetingNameServlet extends HttpServlet {
    Chf_MeetingService c_ms=new Chf_MeetingService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        if(request.getParameter("meeting_name")!=null){
          String meeting_name=request.getParameter("meeting_name");


            String msg="无法判断";
            if(c_ms.judgeName(meeting_name)){
                msg="已存在";
            }else{
                msg="可以使用";
            }
            ObjectMapper om=new ObjectMapper();
            String n_msg=om.writeValueAsString(msg);
            response.setContentType("application/json;charset=utf-8");
            PrintWriter pw=response.getWriter();
            pw.print(n_msg);
            pw.flush();
            pw.close();
        }

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
